# -*- coding: utf-8 -*-
# בש״ד
#
# Teniente Django Template Slots - Part of the Cuba Libre Project
# Copyright (C) 2009, Joshua "jag" Ginsberg <jag@flowtheory.net>
# 
# Para mi amor, que inspira a mi cada respiración y que extraña a Cuba
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from taino.api import Component
from teniente.api import ITemplateSlot

class UserLinksSlot(Component):
    """The Django stock base.html includes a block "userlinks". This slot is
    for those links."""
    
    implements = [ITemplateSlot,]
    component_id = 'com.djangoproject.base.userlinks'
    component_description = 'The user-tools section'
    
    def wrap_token(self, token_html):
        if token_html:
            return u'<li class="userlink">%s</li>' % token_html
        else:
            return u''
    
    def render_slot(self, token_list):
        return u'<ul id="userlinks">' + u'\n'.join(token_list) + u'</ul>'
    
class NavGlobalSlot(Component):
    """The Django stock base.html includes a block "nav-global". This slot is
    for that block."""
    
    implements = [ITemplateSlot,]
    component_id = 'com.djangoproject.base.nav-global'
    component_description = 'The nav-global block'
    
    def wrap_token(self, token_html):
        if token_html:
            return u'<li>%s</li>' % token_html
        else:
            return u''
    
    def render_slot(self, token_list):
        if not token_list:
            return u''
        content = u'\n'.join(token_list)
        return u'<ul id="nav-global">%s</ul>' % content

class ObjectToolsSlot(Component):
    """The Django stock base.html includes a block "object-tools". This slot is
    for that block."""
    
    implements = [ITemplateSlot,]
    component_id = 'com.djangoproject.base.object-tools'
    component_description = 'The object-tools block'
    
    def wrap_token(self, token_html):
        if token_html:
            return u'<li>%s</li>' % token_html
        else:
            return u''
    
    def render_slot(self, token_list):
        if not token_list:
            return u''
        content = u'\n'.join(token_list)
        return u'<ul class="object-tools">%s</ul>' % content

class ContentRelatedSlot(Component):
    """The Django stock base.html includes a block "content-related". This slot
    is for that block."""
    
    implements = [ITemplateSlot,]
    component_id = 'com.djangoproject.base.content-related'
    component_description = 'The content-related block'
    
    def wrap_token(self, token_html):
        return u'<div class="module">%s</div>' % token_html
    
    def render_slot(self, token_list):
        content = u'\n'.join(token_list)
        return u'<div id="content-related">%s</div>' % content

